import type { App } from 'leafer-ui'
import { Ruler } from 'leafer-x-ruler'

let ruler: Ruler | null = null

function createRuler(app: App) {
  ruler = new Ruler(app, {
    theme: 'light',
    unit: 'px',
  })
  return ruler
}

export function startRuler(app: App) {
  const ruler = createRuler(app)
  ruler.enabled = true
}

export function stopRuler() {
  if (!ruler)
    return

  ruler.enabled = false
}
